package com.mfangsoft.zhuangjialong.integration.commentactivity.service.impl;


import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mfangsoft.zhuangjialong.common.context.UserContext;
import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.integration.activity.model.BaseActivityInfo;
import com.mfangsoft.zhuangjialong.integration.commentactivity.mapper.BaseCommentActivityMapper;
import com.mfangsoft.zhuangjialong.integration.commentactivity.model.BaseCommentActivity;
import com.mfangsoft.zhuangjialong.integration.commentactivity.service.CommentActivityService;
import com.mfangsoft.zhuangjialong.integration.user.model.UserEntity;



@Service
public class CommentActivityServiceimpl implements CommentActivityService {
	
	
	private static final Logger LOGGER = LoggerFactory.getLogger(CommentActivityServiceimpl.class); 
	
	
	@Autowired
	private BaseCommentActivityMapper baseCommentActivityMapper;


	@Override
	public void addCommentActivity(BaseCommentActivity baseCommentActivity) {
		
		
//		Map map = new HashMap<>();
//		map.put("activity_id", baseCommentActivity.getActivity_id());
//		map.put("customer_id", baseCommentActivity.getCustomer_id());
//		Integer shopId =  baseCommentActivityMapper.selectShopId(map);
//		
//		baseCommentActivity.setShop_id(shopId);
		baseCommentActivityMapper.addCommentActivity(baseCommentActivity);
	}


	@Override
	public Page<Map<String, Object> > selectCommentActivity(Page<Map<String, Object> > page) {
		UserEntity user = UserContext.getCurrentUser();
		if(user!=null){
			Map<String,Object> map =(Map<String,Object>) page.getParam();
			if(map!=null){
				map.put("level", user.getUser_level());
				map.put("shopId", user.getId());
				page.setParam(map);
				page.setData(baseCommentActivityMapper.selectCommentActivityPage(page));
			}else{
				Map<String,Object> m=new HashMap<>();
				m.put("level", user.getUser_level());
				m.put("shopId", user.getId());
				page.setParam(m);
				page.setData(baseCommentActivityMapper.selectCommentActivityPage(page));
			}
			return page;
		}
		return null;
	
	}


	
	



}
